//
//  AcountCell.m
//  Zhiche-Carriage
//
//  Created by 王亚陆 on 16/11/5.
//  Copyright © 2016年 LeeBruce. All rights reserved.
//

#import "AcountCell.h"
#import <Masonry.h>

@implementation AcountCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self){
        
        self.TimeTitle = [self createUIlabel:@"10-23" andFont:FontOfSize12 andColor:YellowColor];
        [self.contentView addSubview:self.TimeTitle];
        [self.TimeTitle mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.contentView.mas_left).with.offset(16*kWidth);
            make.centerY.mas_equalTo(self.contentView);
        }];
        
        self.moneyTitle = [self createUIlabel:@"+3000.00" andFont:FontOfSize14 andColor:YellowColor];
        [self.contentView addSubview:self.moneyTitle];
        [self.moneyTitle mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.mas_equalTo(self.contentView.mas_top).with.offset(20*kHeight);
            make.left.mas_equalTo(self.contentView.mas_left).with.offset(80*kWidth);
        }];

        
        self.addressTitle = [self createUIlabel:@"江西-萍乡--福建-厦门" andFont:FontOfSize12 andColor:BlackColor];
        [self.contentView addSubview:self.addressTitle];
        [self.addressTitle mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.mas_equalTo(self.moneyTitle.mas_centerY).with.offset(20*kHeight);
            make.left.mas_equalTo(self.contentView.mas_left).with.offset(80*kWidth);
            
        }];

        UIView * viewline = [[UIView alloc]init];
        viewline.backgroundColor = LineGrayColor;
        [self.contentView addSubview:viewline];
        [viewline mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.mas_equalTo(self.contentView.mas_bottom);
            make.left.mas_equalTo(self.contentView.mas_left);
            make.size.mas_equalTo(CGSizeMake(Main_Width, 0.5));
        }];
        
    }
    return self;
}

-(void)showInfo:(NSMutableDictionary*)dic_info{
    
//    arrivalCity = "";
//    arrivalCounty = "";
//    arrivalProvince = "";
//    billId = "<null>";
//    createTime = "2016-11-05 11:53:42";
//    departCity = "";
//    departCounty = "";
//    departProvince = "";
//    id = 445;
//    orderActPay = "-9.98";
//    orderFee = "-10";
//    orderId = "<null>";
//    payType = 20;
//    payTypeText = "<null>";
//    userId = 173;
//    userName = "\U81ea\U817e";
//    userType = 50;
//
    
    NSString * label11 = [NSString stringWithFormat:@"%@",dic_info[@"createTime"]];
    _TimeTitle.text = [label11 substringWithRange:NSMakeRange(5, 5)];
    _moneyTitle.text = [NSString stringWithFormat:@"%@",dic_info[@"orderActPay"]];
    
    if ([dic_info[@"departAddr"] isEqual:[NSNull null]] || [dic_info[@"arrivalAddr"] isEqual:[NSNull null]] ) {
        
        _addressTitle.text = @"";

        
    } else {
        
        _addressTitle.text = [NSString stringWithFormat:@"%@--%@",dic_info[@"departAddr"],dic_info[@"arrivalAddr"]];

    }
    
    
//    NSLog(@"%@",dic_info);
    
    
    
    
    
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}
-(UILabel*)createUIlabel:(NSString *)title andFont:(CGFloat)font andColor:(UIColor*)color {
    UILabel * label =[[UILabel alloc]init];
    label.text = title;
    label.textColor = color;
    UIFont *fnt = [UIFont fontWithName:@"HelveticaNeue" size:font];CGSize size = [label.text sizeWithAttributes:[NSDictionary dictionaryWithObjectsAndKeys:fnt,NSFontAttributeName, nil]];
    CGFloat nameH = size.height;
    CGFloat nameW = size.width;
    label.textAlignment = NSTextAlignmentRight;
    label.frame =CGRectMake(0, 0, nameW, nameH);
    label.font = Font(font);
    return label;
}


@end
